From: Stephen Berman Date: Tue, 8 Jan 2013 21:40:41 +0000 (+0100) Subject: * calendar/todos.el: Fix tabular alignment in Todos Categories mode. X-Git-Tag: archive/raspbian/1%29.2+1-2+rpi1^2~5^2~3675 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/www.github.com/%22bookmarks:///%22http:/www.example.com/cgi/%22https:/www.github.com/%22bookmarks:/?a=commitdiff_plain;h=b58fa72f2ad2f2c268a3e6eb8d884fe0f229dfac;p=emacs.git * calendar/todos.el: Fix tabular alignment in Todos Categories mode. (todos-adjusted-category-label-length): New function. (todos-padded-string): Use it. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 754e936f2b3..c529800e564 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,9 @@ +2013-01-08 Stephen Berman + + * calendar/todos.el: Fix tabular alignment in Todos Categories mode. + (todos-adjusted-category-label-length): New function. + (todos-padded-string): Use it. + 2013-01-08 Stephen Berman * calendar/todos.el (todos-move-item): Allow moving done items to diff --git a/lisp/calendar/todos.el b/lisp/calendar/todos.el index 0b3a3b57a9b..c5792338930 100644 --- a/lisp/calendar/todos.el +++ b/lisp/calendar/todos.el @@ -2141,15 +2141,26 @@ in Todos Filter Items mode." (dolist (c categories longest) (setq longest (max longest (length c)))))) +(defun todos-adjusted-category-label-length () + "Return adjusted length of category label button. +The adjustment ensures proper tabular alignment in Todos +Categories mode." + (let* ((categories (mapcar 'car todos-categories)) + (longest (todos-longest-category-name-length categories)) + (catlablen (length todos-categories-category-label)) + (lc-diff (- longest catlablen))) + (if (and (natnump lc-diff) + (eq (logand lc-diff 1) 1)) ; oddp from cl.el + (1+ longest) + (max longest catlablen)))) + (defun todos-padded-string (str) - "Return string STR padded with spaces. + "Return category name or label string STR padded with spaces. The placement of the padding is determined by the value of user option `todos-categories-align'." - (let* ((categories (mapcar 'car todos-categories)) - (len (max (todos-longest-category-name-length categories) - (length todos-categories-category-label))) + (let* ((len (todos-adjusted-category-label-length)) (strlen (length str)) - (strlen-odd (eq (logand strlen 1) 1)) ; oddp from cl.el + (strlen-odd (eq (logand strlen 1) 1)) (padding (max 0 (/ (- len strlen) 2))) (padding-left (cond ((eq todos-categories-align 'left) 0) ((eq todos-categories-align 'center) padding)